//
//  ProfieViewController.m
//  penzer
//
//  Created by caiyc on 2018/10/2.
//  Copyright © 2018年 caiyc. All rights reserved.
//

#import "ProfieViewController.h"
#import "SGPagingView.h"
#import "SGPageContentCollectionView.h"
#import "TodayLiveViewController.h"
#import "ProfileTotalViewController.h"
#import "ProfieDetailViewController.h"
#import "WithDrawRecViewController.h"
@interface ProfieViewController ()<SGPageTitleViewDelegate, SGPageContentCollectionViewDelegate>
@property (nonatomic, strong) SGPageTitleView *pageTitleView;
@property (nonatomic, strong) SGPageContentCollectionView *pageContentCollectionView;
@end

@implementation ProfieViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    [self setupPageView];
    // Do any additional setup after loading the view from its nib.
}
- (void)setupPageView {
    
    
    CGFloat statusHeight = CGRectGetHeight([UIApplication sharedApplication].statusBarFrame);
    CGFloat pageTitleViewY = 0;
    
    if (statusHeight == 20.0) {
        pageTitleViewY = 64;
    } else {
        pageTitleViewY = 88;
    }
    //pageTitleViewY += self.Top_View.frame.size.height;
    
    NSArray *titleArr = @[@"佣金", @"佣金明细",@"提现记录"];
    SGPageTitleViewConfigure *configure = [SGPageTitleViewConfigure pageTitleViewConfigure];
    //configure.titleColor = [UIColor lightGrayColor];
     configure.titleFont = [UIFont fontWithName:@"Helvetica-Bold" size:18];
    configure.titleSelectedColor = [UIColor blackColor];
    configure.indicatorColor = [UIColor blackColor];
    //    configure.indicatorColor = [UIColor blackColor];
    //  configure.indicatorAdditionalWidth = 80; // 说明：指示器额外增加的宽度，不设置，指示器宽度为标题文字宽度；若设置无限大，则指示器宽度为按钮宽度
    configure.titleGradientEffect = YES;
    
    /// pageTitleView
    self.pageTitleView = [SGPageTitleView pageTitleViewWithFrame:CGRectMake(10,40, screen_width-20, 44) delegate:self titleNames:titleArr configure:configure];
    self.pageTitleView.backgroundColor =[UIColor clearColor];
    [self.view addSubview:_pageTitleView];
    ProfileTotalViewController *vc1 =[[ProfileTotalViewController alloc]init];
    vc1.view.backgroundColor = [UIColor clearColor];
    ProfieDetailViewController *vc2 = [[ProfieDetailViewController alloc]init];
    WithDrawRecViewController *vc3 = [[WithDrawRecViewController alloc]init];

    NSArray *childArr = @[vc1,vc2,vc3];
    /// pageContentCollectionView
    CGFloat ContentCollectionViewHeight = screen_height - CGRectGetMaxY(_pageTitleView.frame)-63;//内嵌的子控制器的视图高度
    self.pageContentCollectionView = [[SGPageContentCollectionView alloc] initWithFrame:CGRectMake(10, CGRectGetMaxY(_pageTitleView.frame)+10, screen_width-20, ContentCollectionViewHeight) parentVC:self childVCs:childArr];
    _pageContentCollectionView.backgroundColor = [UIColor clearColor];
    _pageContentCollectionView.layer.masksToBounds = 1;
    _pageContentCollectionView.layer.cornerRadius = 5;
    _pageContentCollectionView.delegatePageContentCollectionView = self;
    [self.view addSubview:_pageContentCollectionView];
}
- (void)pageTitleView:(SGPageTitleView *)pageTitleView selectedIndex:(NSInteger)selectedIndex {
    [self.pageContentCollectionView setPageContentCollectionViewCurrentIndex:selectedIndex];
}

- (void)pageContentCollectionView:(SGPageContentCollectionView *)pageContentCollectionView progress:(CGFloat)progress originalIndex:(NSInteger)originalIndex targetIndex:(NSInteger)targetIndex {
    [self.pageTitleView setPageTitleViewWithProgress:progress originalIndex:originalIndex targetIndex:targetIndex];
}
/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
